#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

#include "cvtclass_common.hpp"
#include "cvtclass_parser.hpp"
#include "cvtclass_gener.hpp"

static void getOption(int argc, char* argv[], char* pktfile,char* classname)
{
    if ( argc !=  3 )
    {
        pexit_info("Usage:%s pktPath className",BASENAME(argv[0]));
    }
    strcpy(pktfile, argv[1]);
    strcpy(classname,argv[2]);
}

int main(int argc,char* argv[])
{
    char pktfile[128] = { 0 };
    char classname[60] = { 0 };
    getOption(argc,argv,pktfile,classname);

    TLOG_INIT(argv[0]);

    CVTPkt_Parser parser;
    if( parser.CVTPkt_parser(pktfile) != 0)
    {
        pexit_info("cvt_parse pktfile %s error",pktfile);
    }

    auto& object = parser.CVTPkt_getFields();
    infoLog("CVTPkt_Parser (%s) succed. output=[%s]",
        pktfile,ObjectFormat::formatObject(object,2).c_str());

    return CVTPkt_Gener(classname).CVTClass_execute(object);
}
	